<template>
  <div>
    <!-- 表单-->
    <el-form ref="form" :label-position="labelPosition" :model="role" label-width="100px" size="normal">
      <el-form-item label="角色名称">
        <el-input v-model="role.roleName" />
      </el-form-item>
      <el-form-item label="角色编码">
        <el-input v-model="role.roleCode" />
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="role.remark" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="normal" @click="onSubmit">提交</el-button>
        <el-button size="normal" @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { save } from '@/api/role'
export default {
  components: {
    // Tinymce
  },
  data() {
    return {
      labelPosition: 'right',
      role: {}
    }
  },
  mounted() {
  },
  created() {
    this.role = {}
  },
  methods: {
    onSubmit() {
      save(this.role).then(res => {
        // console.log(res)
        if (res.code !== 20000) {
          this.$message.error(res.message)
          this.$emit('fetchData')
          this.$emit('closeAddDialog')
          this.role = {}
        } else {
          this.$message.success(res.message)
          this.$emit('fetchData')
          this.$emit('closeAddDialog')
          this.role = {}
        }
      })
    },
    onCancel() {
      this.$emit('closeAddDialog')
    }
  }
}
</script>
